
import java.awt.Toolkit;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmNuevo.java
 *
 * Created on 28-jul-2011, 11:24:02
 */
/**
 *
 * @author Kid_goth
 */
public class frmNuevo extends javax.swing.JFrame {
frmIndex idx = new frmIndex();
    /** Creates new form frmNuevo */
    public frmNuevo() {
        initComponents();
        Inicio();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        txtPal = new javax.swing.JPasswordField();
        jLabel3 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("JAhorcado - Nuevo");
        setUndecorated(true);
        getContentPane().setLayout(null);

        txtPal.setForeground(new java.awt.Color(255, 0, 51));
        txtPal.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtPalKeyTyped(evt);
            }
        });
        getContentPane().add(txtPal);
        txtPal.setBounds(20, 90, 170, 30);

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("X");
        jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel3MouseClicked(evt);
            }
        });
        getContentPane().add(jLabel3);
        jLabel3.setBounds(260, 0, 30, 20);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel1.setText("Introduzca la Palabra a Resolver........");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(20, 40, 250, 40);

        jButton1.setText("OK");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);
        jButton1.setBounds(200, 90, 60, 30);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/_img_/tituloNue.png"))); // NOI18N
        jLabel2.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                jLabel2MouseDragged(evt);
            }
        });
        getContentPane().add(jLabel2);
        jLabel2.setBounds(0, 0, 275, 136);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        if((txtPal.getText().length() >= 6) || (txtPal.getText().contains(" ")))
        {
            idx.CapPalabra(txtPal.getText().toUpperCase());
            idx.setVisible(true);
            this.setVisible(false); 
        }
        else
        {
            JOptionPane.showMessageDialog(null, "La palabra debe ser minimo de 6 Caracteres", "Palabra Muy Corta", JOptionPane.YES_OPTION);
        }      
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jLabel2MouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseDragged
        this.setLocation
        (
            this.getX() + evt.getX() - this.getWidth() / 2,
            this.getY() + evt.getY() - this.getHeight() / 2 
        );
    }//GEN-LAST:event_jLabel2MouseDragged

    private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel3MouseClicked
        System.exit(0);                    
    }//GEN-LAST:event_jLabel3MouseClicked

    private void txtPalKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPalKeyTyped
        if(txtPal.getText().length() >= 10)
        {
            evt.consume();
        }
    }//GEN-LAST:event_txtPalKeyTyped

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new frmNuevo().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPasswordField txtPal;
    // End of variables declaration//GEN-END:variables
    
    public void Inicio()
    {
        this.setLocation
        (
            Toolkit.getDefaultToolkit().getScreenSize().width / 2 - this.getWidth()/2,
            Toolkit.getDefaultToolkit().getScreenSize().height / 2- this.getHeight()/2
        );
        this.setSize(275, 136);
    }

}
